package com.aracky.system.schedule;

import com.aracky.system.service.WxSyncService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.powerjob.worker.core.processor.ProcessResult;
import tech.powerjob.worker.core.processor.TaskContext;
import tech.powerjob.worker.core.processor.sdk.BasicProcessor;

import java.time.LocalDateTime;

/**
 * @Author zengzhiping
 * @BelongsPackage com.aracky.system.schedule
 * @CreateTime 2022-07-28
 * @Description 微信同步组织任务
 */
@Component
public class SyncWxDataJob implements BasicProcessor {
    private static Logger logger = LoggerFactory.getLogger(SyncWxDataJob.class);

    @Autowired
    private WxSyncService wxSyncService;


    @Override
    public ProcessResult process(TaskContext taskContext) throws Exception {

        logger.info("同步微信部门-用户-岗位数据任务开始时间：{}", LocalDateTime.now());

        // 进行实际处理...
        wxSyncService.syncWxData();

        // 返回结果，该结果会被持久化到数据库，在前端页面直接查看，极为方便
        return new ProcessResult(true, "微信部门-用户-岗位同步成功" + LocalDateTime.now());
    }
}
